<?php
class CMRPageShowSection extends CMRPage
{
	private $section;
	
	public function __construct($database, $section)
	{
		parent::__construct($database);
		$this->section = $section;
	}
	
	protected function getContentsDiv()
	{
		$sectionsPanel = new SectionsPanel($this->section);
		$html = $sectionsPanel->getHTML();
		
		$html .= "<p> This section contains the resources contained in the ".$this->section." section. Choose a category from the list below.</p>\n";
		
		$sql = "SELECT * FROM ".$this->section."CategoryNames ORDER BY Name ";
//		echo $sql."<br>\n";
		$this->Database->ExecuteSQL($sql);
		
		while($row = $this->Database->getRow())
		{
			// get number of resources in this category
			$copyDatabase = $this->Database->recopy();
			$catSQL =  "SELECT res.*,cat.* FROM Resources as res ";
			$catSQL .= "INNER JOIN ".$this->section."Categorys AS cat ON res.ResourceID=cat.ResourceID ";
			$catSQL .= "WHERE DeletedBy = '0' and StatusTypeID = '3' AND cat.".$this->section."CategoryNameID=".$row[$this->section.'CategoryNameID']." ";
			$catSQL .= "ORDER BY ResourceTitle";
//			echo $catSQL."<br>\n";
			$copyDatabase->ExecuteSQL($catSQL);
			$count = $copyDatabase->getNumRows();
			if ($count == 0 ) $count = "No";
			
		    $html .= "<div class=\"Section\" id=\"SectionHTML".$row[$this->section."CategoryNameID"]."\" onMouseOver=\"OnMouseOverSection('SectionHTML".$row[$this->section."CategoryNameID"]."');\" onMouseOut=\"OnMouseOutSection('SectionHTML".$row[$this->section."CategoryNameID"]."');\" onClick=\"Show".$this->section."Category(".$row[$this->section."CategoryNameID"].");\">\n";
			$html .= "<div id=\"ShowSectionName\">".$row['Name']."<br><small><small>(".$count." resources)</small></small></div>\n";
			$html .= "<div id=\"ShowSectionDescription\">".$row['Description']."</div>\n";
//			$browseImageID = "BrowseButton".$this->section.$row[$this->section."CategoryNameID"];
//			$html .= "<div onclick=\"Show".$this->section."Category(".$row[$this->section."CategoryNameID"].")\" id=\"ShowSectionGoto\"><img id=\"".$browseImageID."\" onMouseOver=\"OnMouseOverBrowse('".$browseImageID."');\" onMouseOut=\"OnMouseOutBrowse('".$browseImageID."');\" src=\"../Images/Browse.png\" /></div>\n";
			$html .= "<p class=\"floatstop\" />\n";
			$html .= "</div>\n";
		}
				
		$html .= "</div>\n";
		return $html;
	}
	
}